package com.demo.util;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;

public class ReadExcel {
	public List<String> ReadExcelColumn(String path) {
		List<String> assetList = new ArrayList<String>();
		jxl.Workbook readwb = null;
		InputStream instream = null;
		try {
			instream = new FileInputStream(path);
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			readwb = Workbook.getWorkbook(instream);
		} catch (BiffException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		// 获取第一张Sheet表
		Sheet readsheet = readwb.getSheet(0);
		// 获取总行数
		int rsRows = readsheet.getRows();
		for (int i = 1; i < rsRows; i++) {
			Cell cell = readsheet.getCell(0, i);
			assetList.add(cell.getContents());
			// System.out.println(assetList);
		}
		// System.out.println(assetList.toString());
		return assetList;
	}
}
